﻿using Newtonsoft.Json;
using SearchServer;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TCP服务器端;

class PTManager
{
    public static void CheckPT(string s)
    {
        string[] s1 = s.Split('|');
        Console.WriteLine(s1);
        if (s1[0]=="PTransform")
        {
            PTransform ptt= JsonConvert.DeserializeObject<PTransform>(s1[1]);
            s=JsonConvert.SerializeObject(ptt);
        }
        else if (s1[0]=="PTLogin")
        {
            PTLogin ptt = JsonConvert.DeserializeObject<PTLogin>(s1[1]);
            ptt.clientId = Program.id;
            s = JsonConvert.SerializeObject(ptt);
        }
        s = s1[0] +'|'+s;
        if (s1[0]=="PTLogin")
        {
            Program.id++;
        }

       
        //Console.WriteLine("广播协议" +s);
        ClientManager.BroadCastToClientSockets(s, s.Length);
    }
}

